/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Principal.java
 *
 * Created on 08/03/2011, 09:06:07
 */

package sisgraf.view;
import java.math.BigDecimal;
import sisgraf.model.Pedido;
import sisgraf.controler.PedidoControler;

/**
 *
 * @author jordan
 */
public class Pedidos extends javax.swing.JDialog {
    private int opcao=0;
    private PedidoControler pedidoControler;
    private Pedido pedido;
    private boolean incluiu=false;
    
    /** Creates new form Principal */
    public Pedidos(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }
    public void setOpcao(int opcao)
    {
        this.opcao = opcao;
        formComponentResized(null);
        setLocationRelativeTo(null);
        jTxFdId.setText(pedido.getId().toString());
        jTxFdIdOrcamento.setText(pedido.getItemOrcamento().getOrcamento().getId().toString());
        jTxFdIdItemOrcamento.setText(pedido.getItemOrcamento().getId().toString());
        jTxFdDescricao.setText(pedido.getItemOrcamento().getDescricao());
        jTxFdCliente.setText(pedido.getItemOrcamento().getOrcamento().getCliente().getNom_cli());
        jTxFdVendedor.setText(pedido.getItemOrcamento().getOrcamento().getVendedor().getNom_ven());
        jTxFdDataEntrega.setText(pedido.getDataEntregaForm());
        jTxFdDataPrevisaoEntrega.setText(pedido.getDataPrevisaoEntregaForm());
        jTxFdDataFaturamento.setText(pedido.getDataFaturamentoForm());
        jTxFdValor.setText(pedido.getValorForm());
        jTxFdObsOrc.setText(pedido.getObsOrc());
        jTxFdObservacoes.setText(pedido.getObservacoes());
        if (this.opcao == Menu.OP_PESQ_ALT){
            jTxFdDataEntrega.setEnabled(Menu.estadoPerfil.getPermissao("ped", "CC"));
            jTxFdDataFaturamento.setEnabled(Menu.estadoPerfil.getPermissao("ped", "FA"));
            if (pedido.getDataCancelamento()!=null || pedido.getDataFaturamento()!=null|| pedido.getDataEntrega()!=null){
                jTxFdDataPrevisaoEntrega.setEnabled(false);
                jTxFdDataEntrega.setEnabled(false);
                jTxFdDataFaturamento.setEnabled(false);
                jTxFdValor.setEnabled(false);
                jTxFdObservacoes.setEnabled(false);
                jBtConfirmar.setVisible(false);
            }
        } else {
            jTxFdDataPrevisaoEntrega.setEnabled(false);
            jTxFdDataEntrega.setEnabled(false);
            jTxFdDataFaturamento.setEnabled(false);
            jTxFdValor.setEnabled(false);
            jTxFdObservacoes.setEnabled(false);
            jBtConfirmar.setVisible(false);
        }
        setVisible(true);
        jTxFdDataPrevisaoEntrega.setFocusable(true);
    }
    public void setPedido(Pedido pedido){
        this.pedido = pedido;
    }
    public void setControler(PedidoControler pedidoControler){
        this.pedidoControler = pedidoControler;
    }
    public boolean getncluiu(){
        return this.incluiu;
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPnlSuperior = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jPnlCentral = new javax.swing.JPanel();
        jPnlConteudo = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jTxFdId = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jTxFdIdOrcamento = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jTxFdIdItemOrcamento = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jTxFdDescricao = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jTxFdCliente = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jTxFdVendedor = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTxFdObsOrc = new javax.swing.JTextArea();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTxFdObservacoes = new javax.swing.JTextArea();
        jTxFdDataPrevisaoEntrega = new javax.swing.JFormattedTextField();
        jTxFdDataEntrega = new javax.swing.JFormattedTextField();
        jTxFdDataFaturamento = new javax.swing.JFormattedTextField();
        jTxFdValor = new javax.swing.JFormattedTextField();
        jPnlControle = new javax.swing.JPanel();
        jBtConfirmar = new javax.swing.JButton();
        jBtFinalizar = new javax.swing.JButton();
        jPnlInferior = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                formWindowClosed(evt);
            }
        });
        addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentResized(java.awt.event.ComponentEvent evt) {
                formComponentResized(evt);
            }
        });

        jPnlSuperior.setBorder(new javax.swing.border.MatteBorder(null));

        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("SISTEMA DE ORÇAMENTOS PARA SERVIÇOS GRAFICOS");
        jLabel1.setMinimumSize(new java.awt.Dimension(0, 14));

        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel2.setText("Alteração de Pedidos");
        jLabel2.setMinimumSize(new java.awt.Dimension(0, 14));

        javax.swing.GroupLayout jPnlSuperiorLayout = new javax.swing.GroupLayout(jPnlSuperior);
        jPnlSuperior.setLayout(jPnlSuperiorLayout);
        jPnlSuperiorLayout.setHorizontalGroup(
            jPnlSuperiorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 629, Short.MAX_VALUE)
            .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 629, Short.MAX_VALUE)
        );
        jPnlSuperiorLayout.setVerticalGroup(
            jPnlSuperiorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPnlSuperiorLayout.createSequentialGroup()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jPnlCentral.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPnlCentral.setMinimumSize(new java.awt.Dimension(100, 0));

        jPnlConteudo.setBorder(javax.swing.BorderFactory.createLineBorder(null));

        jLabel5.setText("N. Pedido:");

        jTxFdId.setEnabled(false);

        jLabel6.setText("N. Orçamento:");

        jTxFdIdOrcamento.setEnabled(false);

        jLabel7.setText("Item Orçamento:");

        jTxFdIdItemOrcamento.setEnabled(false);

        jLabel8.setText("Serviço:");

        jTxFdDescricao.setEnabled(false);

        jLabel9.setText("Cliente:");

        jTxFdCliente.setEnabled(false);

        jLabel10.setText("Vendedor:");

        jTxFdVendedor.setEnabled(false);

        jLabel11.setText("Previsão de Entrega:");

        jLabel12.setText("Entrega:");

        jLabel13.setText("Faturamento:");

        jLabel14.setText("Valor:");

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Observações do Orçamento", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 0, 0))); // NOI18N

        jTxFdObsOrc.setColumns(20);
        jTxFdObsOrc.setRows(5);
        jTxFdObsOrc.setEnabled(false);
        jScrollPane1.setViewportView(jTxFdObsOrc);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 609, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1)
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Observações do Pedido", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 0, 0))); // NOI18N

        jTxFdObservacoes.setColumns(20);
        jTxFdObservacoes.setRows(5);
        jScrollPane2.setViewportView(jTxFdObservacoes);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 609, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 99, Short.MAX_VALUE)
        );

        try {
            jTxFdDataPrevisaoEntrega.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        try {
            jTxFdDataEntrega.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        try {
            jTxFdDataFaturamento.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        jTxFdValor.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#,##0.00"))));
        jTxFdValor.setHorizontalAlignment(javax.swing.JTextField.RIGHT);

        javax.swing.GroupLayout jPnlConteudoLayout = new javax.swing.GroupLayout(jPnlConteudo);
        jPnlConteudo.setLayout(jPnlConteudoLayout);
        jPnlConteudoLayout.setHorizontalGroup(
            jPnlConteudoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPnlConteudoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPnlConteudoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPnlConteudoLayout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTxFdCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 242, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTxFdVendedor, javax.swing.GroupLayout.DEFAULT_SIZE, 264, Short.MAX_VALUE))
                    .addGroup(jPnlConteudoLayout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTxFdId, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTxFdIdOrcamento, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTxFdIdItemOrcamento, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTxFdDescricao, javax.swing.GroupLayout.DEFAULT_SIZE, 182, Short.MAX_VALUE))
                    .addGroup(jPnlConteudoLayout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTxFdDataPrevisaoEntrega, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTxFdDataEntrega, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTxFdDataFaturamento, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel14)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTxFdValor, javax.swing.GroupLayout.DEFAULT_SIZE, 111, Short.MAX_VALUE)))
                .addContainerGap())
            .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPnlConteudoLayout.setVerticalGroup(
            jPnlConteudoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPnlConteudoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPnlConteudoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jTxFdId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(jTxFdIdOrcamento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7)
                    .addComponent(jTxFdIdItemOrcamento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8)
                    .addComponent(jTxFdDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPnlConteudoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jTxFdCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10)
                    .addComponent(jTxFdVendedor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPnlConteudoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(jTxFdDataPrevisaoEntrega, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12)
                    .addComponent(jTxFdDataEntrega, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel13)
                    .addComponent(jTxFdDataFaturamento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel14)
                    .addComponent(jTxFdValor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPnlControle.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        jBtConfirmar.setText("Confirmar");
        jBtConfirmar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtConfirmarActionPerformed(evt);
            }
        });

        jBtFinalizar.setText("Finalizar");
        jBtFinalizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtFinalizarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPnlControleLayout = new javax.swing.GroupLayout(jPnlControle);
        jPnlControle.setLayout(jPnlControleLayout);
        jPnlControleLayout.setHorizontalGroup(
            jPnlControleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPnlControleLayout.createSequentialGroup()
                .addContainerGap(445, Short.MAX_VALUE)
                .addComponent(jBtConfirmar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jBtFinalizar)
                .addGap(20, 20, 20))
        );
        jPnlControleLayout.setVerticalGroup(
            jPnlControleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPnlControleLayout.createSequentialGroup()
                .addContainerGap(17, Short.MAX_VALUE)
                .addGroup(jPnlControleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jBtFinalizar)
                    .addComponent(jBtConfirmar))
                .addContainerGap())
        );

        javax.swing.GroupLayout jPnlCentralLayout = new javax.swing.GroupLayout(jPnlCentral);
        jPnlCentral.setLayout(jPnlCentralLayout);
        jPnlCentralLayout.setHorizontalGroup(
            jPnlCentralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPnlControle, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPnlConteudo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPnlCentralLayout.setVerticalGroup(
            jPnlCentralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPnlCentralLayout.createSequentialGroup()
                .addComponent(jPnlConteudo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPnlControle, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPnlInferior.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabel3.setText("Gráfica Modêlo");

        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel4.setText("Grupo de Estudo PMA Anhanguera");

        javax.swing.GroupLayout jPnlInferiorLayout = new javax.swing.GroupLayout(jPnlInferior);
        jPnlInferior.setLayout(jPnlInferiorLayout);
        jPnlInferiorLayout.setHorizontalGroup(
            jPnlInferiorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPnlInferiorLayout.createSequentialGroup()
                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 311, Short.MAX_VALUE)
                .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jPnlInferiorLayout.setVerticalGroup(
            jPnlInferiorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPnlInferiorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jLabel3))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPnlSuperior, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPnlInferior, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPnlCentral, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPnlSuperior, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPnlCentral, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPnlInferior, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    private void formComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentResized
        // TODO add your handling code here:
        int dif = this.getHeight()-jPnlSuperior.getHeight()-jPnlCentral.getHeight()-jPnlInferior.getHeight()-6;
        jPnlCentral.setSize(this.getWidth(),this.getHeight()-jPnlSuperior.getHeight()-jPnlInferior.getHeight()-dif);
        jPnlConteudo.setSize(jPnlCentral.getWidth(),jPnlCentral.getHeight()-jPnlControle.getHeight());
        jPnlControle.setSize(jPnlCentral.getWidth(), jPnlControle.getHeight());
        jPnlControle.setLocation(0, jPnlConteudo.getHeight());
    }//GEN-LAST:event_formComponentResized

    private void jBtFinalizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtFinalizarActionPerformed
        // TODO add your handling code here:
        if (this.opcao == Menu.OP_PESQ_CON)this.dispose();
        boolean mudou = false;
        /*
         *
        if (!pedido.getDataPrevisaoEntregaForm().equals(jTxFdDataPrevisaoEntrega.getText())) mudou=true;
        if (!pedido.getDataEntregaForm().equals(jTxFdDataEntrega.getText())) mudou=true;
        if (!pedido.getDataFaturamentoForm().equals(jTxFdDataFaturamento.getText())) mudou=true;
        if (!pedido.getValorForm().equals(jTxFdValor.getText())) mudou=true;
        if (!pedido.getObservacoes().equals(jTxFdObservacoes.getText())) mudou=true;
         */
        if (mudou){
            if (javax.swing.JOptionPane.showConfirmDialog(null,
                    "Modificações foram feitas, deseja realmente finalizar sem salvar ?",
                    "Finalizar", javax.swing.JOptionPane.YES_NO_OPTION)==0){
                Pedidos.this.dispose();
            }
        } else Pedidos.this.dispose();
    }//GEN-LAST:event_jBtFinalizarActionPerformed

    private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
        // TODO add your handling code here:
        pedidoControler.liberarPedido();

    }//GEN-LAST:event_formWindowClosed

    private void jBtConfirmarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtConfirmarActionPerformed
        // TODO add your handling code here:
        boolean gravarOk = true;
        String mensErro="Dados não puderam ser salvos, apresentaram os seguintes erro:";
        if (!Menu.validaData(jTxFdDataPrevisaoEntrega.getText())){
            gravarOk=false;
            mensErro+="\nData de Previsão de entrega invalida";
        }
        if (!Menu.validaDataBranco(jTxFdDataEntrega.getText())){
            gravarOk=false;
            mensErro+="\nData de entrega invalida invalida";
        }
        if (!Menu.validaDataBranco(jTxFdDataFaturamento.getText())){
            gravarOk=false;
            mensErro+="\nData de faturamento invalida invalida";
        }
        BigDecimal vuBd = new BigDecimal("0");
        if (jTxFdValor.getText().equals("")){
            mensErro = mensErro + "\nInforme o Valor";
            gravarOk=false;
        } else {
            String vu = this.jTxFdValor.getText();
            vu=Menu.removeChar(vu, '.');
            vu=vu.replace(',', '.');
            vuBd = new BigDecimal(vu);
            BigDecimal min = new BigDecimal("0");
            BigDecimal max = new BigDecimal("99999999999.99");
            if (vuBd.compareTo(min)<=0||vuBd.compareTo(max)>0){
                mensErro = mensErro + "\nValor deve ser maior que zero e menor que 99.999.999.999,99";
                gravarOk=false;
            }
        }
        if (gravarOk){
            pedido.setDataEntrega(jTxFdDataEntrega.getText());
            pedido.setDataFaturamento(jTxFdDataFaturamento.getText());
            pedido.setDataPrevisaoEntrega(jTxFdDataPrevisaoEntrega.getText());
            pedido.setObservacoes(jTxFdObservacoes.getText());
            pedido.setValor(vuBd);
            if (!pedidoControler.alterarPedido(pedido)){
                javax.swing.JOptionPane.showMessageDialog(null,
                        "Erro na atualização dos dados do pedido",
                        "Acesso ao Banco de Dados",
                        javax.swing.JOptionPane.INFORMATION_MESSAGE);
            }
            this.dispose();
        } else {
           javax.swing.JOptionPane.showMessageDialog(null,
                   mensErro+"\n"
                   + "Corrija as infromações listadas e tente confirmar novamente ",
                   "Acesso ao Banco de Dados", javax.swing.JOptionPane.INFORMATION_MESSAGE);
        }

    }//GEN-LAST:event_jBtConfirmarActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                Principal dialog = new Principal(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBtConfirmar;
    private javax.swing.JButton jBtFinalizar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPnlCentral;
    private javax.swing.JPanel jPnlConteudo;
    private javax.swing.JPanel jPnlControle;
    private javax.swing.JPanel jPnlInferior;
    private javax.swing.JPanel jPnlSuperior;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextField jTxFdCliente;
    private javax.swing.JFormattedTextField jTxFdDataEntrega;
    private javax.swing.JFormattedTextField jTxFdDataFaturamento;
    private javax.swing.JFormattedTextField jTxFdDataPrevisaoEntrega;
    private javax.swing.JTextField jTxFdDescricao;
    private javax.swing.JTextField jTxFdId;
    private javax.swing.JTextField jTxFdIdItemOrcamento;
    private javax.swing.JTextField jTxFdIdOrcamento;
    private javax.swing.JTextArea jTxFdObsOrc;
    private javax.swing.JTextArea jTxFdObservacoes;
    private javax.swing.JFormattedTextField jTxFdValor;
    private javax.swing.JTextField jTxFdVendedor;
    // End of variables declaration//GEN-END:variables
    
}
